//
//  MSMacros.h
//  Musou
//
//  Created by danal on 13-1-28.
//
//

#import <Foundation/Foundation.h>

#ifdef DEBUG
#define ECHO(...) NSLog(__VA_ARGS__)
#else
#define ECHO(...)
#endif

//Common
#define NUMBERi(i) [NSNumber numberWithInt:i]
#define NUMBERf(f) [NSNumber numberWithFloat:f]
#define STRING(...) [NSString stringWithFormat:__VA_ARGS__]

#define MSDocumentPath(path) [NSString stringWithFormat:@"%@/Documents/%@",NSHomeDirectory(),path]
#define MSCachePath(path) [NSString stringWithFormat:@"%@/Library/Caches/%@",NSHomeDirectory(),path]

#define Localized(text) NSLocalizedString(text, nil)

#define MAIN_QUEUE dispatch_get_main_queue()
#define GLOBAL_QUEUE dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)

//#deinfe MSISPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IPHONE5 [[UIScreen mainScreen] bounds].size.height == 568 ? YES : NO

//Notification
#define MSNotificationCenterAddObserver(selector_, name_) [[NSNotificationCenter defaultCenter] addObserver:self selector:selector_ name:name_ object:nil]
#define MSNotificationCenterRemoveObserver() [[NSNotificationCenter defaultCenter] removeObserver:self]
#define MSNotificationCenterPost(name_, obj_) [[NSNotificationCenter defaultCenter] postNotificationName:name_ object:obj_]

//ARC & RC
#if !__has_feature(objc_arc)
//-fno-objc-arc
#define MSAutorelease(_v) [_v autorelease];
#define MSRetain(_v) [_v retain];
#define MSRelease(_v) [_v release]; _v = nil;
#define MSDealloc(_v) [_v dealloc];
#define MSBridge

#else
// -fobjc-arc
#define MSAutorelease(_v) _v;
#define MSRetain(_v)  _v;
#define MSRelease(_v)
#define MSDealloc(_v)
#define MSBridge __bridge
#endif

//#if(!__has_feature(objc_arc))
//#if(!ARC_ENABLED)
/*
 #ifndef STRONG
 #if __has_feature(objc_arc)
 #define STRONG strong
 #else
 #define STRONG retain
 #endif
 #endif
 
 #ifndef WEAK
 #if __has_feature(objc_arc_weak)
 #define WEAK weak
 #elif __has_feature(objc_arc)
 #define WEAK unsafe_unretained
 #else
 #define WEAK assign
 #endif
 #endif
 
 #if __has_feature(objc_arc)
 #define AUTORELEASE(exp) exp
 #define RELEASE(exp) exp
 #define RETAIN(exp) exp
 #else
 #define AUTORELEASE(exp) [exp autorelease]
 #define RELEASE(exp) [exp release]
 #define RETAIN(exp) [exp retain]
 #endif
 */
